package com.lsx.Mapper;

import com.lsx.entity.Account;
import com.lsx.entity.Wallet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface AppShopMapper {
    /**
     * 根据wid查询钱包数据
     * @param wid
     * @return
     */
    @Select("select * from Wallet where wid=#{wid}")
    Wallet queruRamaining(Integer wid);

    /**
     * 消费100元
     * @param wid
     */
    @Update("update Wallet set remaining = remaining-100 where wid=#{wid}")
    void consume100(Integer wid);

    /**
     * 退款20元
     * @param wid
     */
    @Update("update Wallet set remaining = remaining+20 where wid=#{wid}")
    void refund20(Integer wid);

    /**
     * 查询钱包账单明细
     * @param wid
     * @return
     */
    @Select("select a.* from Account Account a,Wallet w where a.aid=w.account_id and w.wid=#{wid}")
    Account accountDetails(Integer wid);
}
